home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / include / stdio.h < prev    next >
C/C++ Source or Header  |  1996-01-30  |  4KB  |  166 lines

  1. /* This is file stdio.h */
  2. /* This file may have been modified by DJ Delorie (Jan 1991).  If so,
  3. ** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave,
  4. ** Rochester NH, 03867-2954, USA.
  5. */
  6.  
  7. #ifndef _stdio_h_
  8. #define _stdio_h_
  9.  
  10. #include <stddef.h> /* for size_t */
  11.  
  12. #ifndef    STDC_HEADERS
  13. #define STDC_HEADERS
  14. #endif
  15.  
  16. #define BUFSIZ  4096
  17.  
  18. extern  struct  _iobuf {
  19.     int        _cnt;
  20.     char*    _ptr;
  21.     char*    _base;
  22.     int        _bufsiz;
  23.     short    _flag;
  24.     short    _file;
  25. } _iob[];
  26.  
  27. typedef struct _iobuf FILE;
  28.  
  29. #define _IOFBF    00000
  30. #define _IOREAD   00001
  31. #define _IOWRT    00002
  32. #define _IONBF    00004
  33. #define _IOMYBUF  00010
  34. #define _IOEOF    00020
  35. #define _IOERR    00040
  36. #define _IOSTRG   00100
  37. #define _IOLBF    00200
  38. #define _IORW     00400
  39. #define _IOAPPEND 01000
  40. #define _IOTEXT   02000  /* for MSDOS cr/lf style files */
  41.  
  42. #define FILENAME_MAX    160 /* in case of ../../../../../../... */
  43. #define FOPEN_MAX    256
  44. #define TMP_MAX        FILENAME_MAX
  45.  
  46. #define EOF       (-1)
  47.  
  48. #ifndef NULL
  49. #define NULL      0
  50. #endif
  51.  
  52. #define stdin     (&_iob[0])
  53. #define stdout    (&_iob[1])
  54. #define stderr    (&_iob[2])
  55. #define stdaux    (&_iob[3])
  56. #define stdprn    (&_iob[4])
  57.  
  58. #define getc(p) (--(p)->_cnt>=0 ? \
  59.   (int)(*(unsigned char*)(p)->_ptr++) : \
  60.   _filbuf(p))
  61. #define putc(x,p) (--(p)->_cnt>=0? \
  62.   ((int)((unsigned char)((*(p)->_ptr++=(unsigned)(x))))): \
  63.   _flsbuf((unsigned)(x),p))
  64.  
  65. typedef long fpos_t;
  66. #define fgetpos(stream, pos) (((*(pos) = ftell(stream)) == -1) ? -1 : 0)
  67. #define fsetpos(stream, pos) (fseek((stream), *(pos), SEEK_SET))
  68.  
  69. extern void (clearerr) (FILE *);
  70. extern void (_fwalk) (void (*)(FILE *));
  71. extern int (fpurge) (FILE *);
  72. extern int (getc) (FILE *);
  73. extern int (putc) (int, FILE *);
  74. extern int (feof) (FILE *);
  75. extern int (ferror) (FILE *);
  76. extern int (fileno) (FILE *);
  77.  
  78. #define clearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))
  79. #define getchar()   getc(stdin)
  80. #define putchar(x)  putc(x,stdout)
  81. #define feof(p)     (((p)->_flag&_IOEOF)!=0)
  82. #define ferror(p)   (((p)->_flag&_IOERR)!=0)
  83. #define fileno(p)   ((p)->_file)
  84.  
  85. #ifdef __cplusplus
  86. extern "C" {
  87. #endif
  88.  
  89. int    _doprnt(const char*, void *, FILE*);
  90. int    _doscan(FILE*, const char*, void **argp);
  91. int    _doscan_low(FILE *, int (*)(FILE *), int (*)(int, FILE *),
  92.                    const char *, void **);
  93. int    _filbuf(FILE*);
  94. int    _flsbuf(unsigned, FILE*);
  95. int    fclose(FILE*);
  96. int    fcloseall(void);
  97. FILE*  fdopen(int, const char*);
  98. int    fflush(FILE*);
  99. int    fgetc(FILE*);
  100. char*  fgets(char*, int, FILE *);
  101. FILE*  fopen(const char*, const char*);
  102. int    fprintf(FILE*, const char*, ...);
  103. int    fputc(int, FILE*);
  104. int    fputs(const char*, FILE*);
  105. size_t fread(void*, size_t, size_t, FILE*);
  106. FILE*  freopen(const char*, const char*, FILE*);
  107. int    fscanf(FILE*, const char*, ...);
  108. int    fseek(FILE*, long, int);
  109. long   ftell(FILE *);
  110. size_t fwrite(const void*, size_t, size_t, FILE*);
  111. char*  gets(char*);
  112. int    getw(FILE*);
  113. int    pclose(FILE*);
  114. FILE*  popen(const char*, const char*);
  115. int    printf(const char*, ...);
  116. int    puts(const char*);
  117. int    putw(int, FILE*);
  118. void   rewind(FILE*);
  119. int    scanf(const char*, ...);
  120. void   setbuf(FILE*, char*);
  121. void   setbuffer(FILE*, char*, int);
  122. void   setlinebuf(FILE*);
  123. int    setvbuf(FILE*, char*, int, int);
  124. int    sprintf(char*, const char*, ...);
  125. int    sscanf(const char*, const char*, ...);
  126. FILE*  tmpfile(void);
  127. int    ungetc(int, FILE*);
  128. int    vfprintf(FILE*, const char*, ...);
  129. int    vprintf(const char*, ... );
  130. int    vsprintf(char*, const char*, ...);
  131.  
  132. #ifdef __cplusplus
  133. }
  134. #endif
  135.  
  136. #ifndef L_ctermid
  137. #define L_ctermid       9 
  138. #endif
  139. #ifndef L_cuserid
  140. #define L_cuserid       9
  141. #endif
  142. #ifndef P_tmpdir
  143. #define P_tmpdir    "/tmp"
  144. #endif
  145. #ifndef L_tmpnam
  146. #define L_tmpnam    (sizeof(P_tmpdir) + 15)
  147. #endif
  148.  
  149. #ifndef alloca
  150. #define alloca(x)  __builtin_alloca(x)
  151. #endif
  152.  
  153. #ifndef SEEK_SET
  154. #define SEEK_SET 0
  155. #endif
  156.  
  157. #ifndef SEEK_CUR
  158. #define SEEK_CUR 1
  159. #endif
  160.  
  161. #ifndef SEEK_END
  162. #define SEEK_END 2
  163. #endif
  164.  
  165. #endif /* _stdio_h_ */
  166.